package com.yunhe.inspect.repository;
import com.yunhe.inspect.domain.DataInspectOrder;
import com.yunhe.inspect.domain.OrgPeopleInspectAnalysis;
import com.yunhe.inspect.domain.ProportionOfFormsByDepartment;
import com.yunhe.inspect.model.*;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @description 巡检工单表
 * @author misty
 * @date 2021-11-10
 */
@Repository
public interface DataInspectOrderRepository {

    /**
     * 新增
     * @author misty
     * @date 2021/11/10
     **/
    int createDataInspectOrder(DataInspectOrder dataInspectOrder);

    /**
     * 新增
     * @author misty
     * @date 2021/11/10
     **/
    int createDataInspectOrderSelective(DataInspectOrder dataInspectOrder);

    /**
     * 刪除
     * @author misty
     * @date 2021/11/10
     **/
    int deleteDataInspectOrderByPrimaryKey(@Param("id") int id);

    /**
     * 更新
     * @author misty
     * @date 2021/11/10
     **/
    int updateDataInspectOrderByPrimaryKey(DataInspectOrder dataInspectOrder);

    DataInspectOrderForWechatDTO findDataInspectOrderByIdForWechat(@Param("id")int id);

    /**
     * 更新
     * @author misty
     * @date 2021/11/10
     **/
    int updateDataInspectOrderByPrimaryKeySelective(DataInspectOrder dataInspectOrder);

    /**
     * 根据主键查询
     * @author misty
     * @date 2021/11/10
     **/
    DataInspectOrder searchDataInspectOrderByPrimaryKey(@Param("id") int id);


    void batchDataInspectOrder(List<DataInspectOrder> dataInspectOrders);

    List<DataInspectOrderVo> findDataInspectOrder(DataInspectOrderQueryCondition dataInspectOrderQueryCondition);

    void deleteDataInspectOrderByQueryCondition(DataInspectOrderQueryCondition dataInspectOrderQueryCondition);

    void deleteDataInspectOrderByIds(@Param("ids") List<Integer> ids,@Param("headerUser")  Long headerUser);

    List<DataInspectOrder> findDataInspectOrderByNoInspectOrderInspector();

    //查询历史巡检
    List<HistoryResponseVO> getHistoryList(HistoryQueryCondition queryVO);
    /**
     * @Descriptionc 根据条件获取巡检工单列表(App端)
     * @Param InspectOrderAppCondition inspectOrderAppCondition
     * @Return List<DataInspectOrder>
     * @Date 2021/11/11 14:27
     */
    List<DataInspectOrder> getDataInspectOrderByConditionApp(InspectOrderAppCondition inspectOrderAppCondition);

    List<DataInspectOrder> getUnFinishInspectOrder();

    /**
     * 根据条件获取巡检工单列表(微信端)
     * @param inspectOrderWechatCondition inspectOrderWechatCondition
     * @return List<DataInspectOrder>
     */
    List<DataInspectOrder> getDataInspectOrderByConditionForWechat(InspectOrderWechatCondition inspectOrderWechatCondition);

    /**查询完成的单子大于0的组织*/
    List<Long> getOrgForGreaterThanTenInspectionForm();

    /**根据组织id统计每人的巡检单数量*/
    List<OrgPeopleInspectAnalysis> countNumberOfInspectionOrders(Map<String, Object> map);

    /**
     * 根据部门id 查询部门工单数量
     * 时间是根据工单生成的时间
     * @param map orgId，startTime，endTime
     * @return ProportionOfFormsByDepartment
     */
    ProportionOfFormsByDepartment countNumberOfInspectionOrdersForEachDepartment(Map<String, Object> map);

    /**
     * 根据部门id 查询部门工单数量
     * 时间是根据工单生成的时间
     * @param map orgId, inspectStatus, formStatus, startTime, endTime
     * @return Long
     */
    Long countNumberOfInspectionOrdersForOrgId(Map<String, Object> map);
}